<?php
	require_once (dirname(__FILE__)."/../config/api.inc");
	require_once (dirname(__FILE__)."/../config/Config.inc");
	
	$parm = requestArrayParm($_REQUEST);
	
	$shu = base_convert('x2qxvn',36,10);
	
	$result['status'] = '1';
	
	//获取banner(touch)
	unset($wheres,$pages,$sorts);
	$wheres['type'] = 'touch';
	$wheres['status'] = '2';
	
	$wheres['start'] = array('<=',time());
	$wheres['end'] = array('>=',time());
	
	$sorts['sort'] = 'desc';
	
	$resData = _SqlTool::getList('banner', $wheres,$pages, $sorts);
	
	foreach ($resData as $key => $value)
	{
		unset($temp);
		$temp['title'] = $value['title'];
		$temp['img'] = "https://resource.jinfumeng.com/".$value['tupian'];
		$temp['url'] = $value['url'];
		$result['banner'][] = $temp;
	}
	
	
	//获取首页产品推荐
	
	unset($where);
	$where['type'] = 'index';
		
	$tuijian = _SqlTool::getInfo('tuijian', $where);
	
	if(!empty($tuijian))
	{
		$items = json_decode($tuijian['content'],TRUE);
		
		foreach ($items as $key => $val)
		{
			unset($query);
			$query['id'] = $val;
			$query['cp_status'] = '2';
			$chanpin = _SqlTool::getInfo('chanpin', $query);
			if($chanpin)
			{
				unset($query);
				$query['id'] = $chanpin['pt_id'];
				$pingtai = _SqlTool::getInfo('pingtai', $query);
				
				unset($temp);
				$temp['id'] = $chanpin['id'];
				$temp['logo'] = OSS_URL.$pingtai['pt_logo'];
				$temp['name'] = $chanpin['cp_mc'];
				$temp['style'] = $CP_FS[$chanpin['cp_style']];
				$temp['yqnh'] = $chanpin['cp_yqnh'];
				if($chanpin['cp_type'] == '1')
				{
					unset($query);
					$query['cp_id'] = $chanpin['id'];
					$temp['zgfl'] = _SqlTool::getMax('cp_gdfa', $query, $between, 'fanli');
				}
				if($chanpin['cp_type'] == '2')
				{
					$temp['zgfl'] = $chanpin['cp_fl'];
				}
				
				$temp['qixian'] = $chanpin['cp_tzqx'];
				$temp['qixianlx'] = $chanpin['cp_tzqxlx'];
				
				
				$temp['qtje'] = $chanpin['cp_qtje'];
				$temp['url'] = SITE_URL."skip.php?id=".$chanpin['id'].'&loginkey='.$parm['loginkey'];
				$temp['type'] = $chanpin['cp_type'];
				
				$temp['cp_lxxs'] = $chanpin['cp_lxxs'];
				$temp['is_new'] = $chanpin['is_new'];
				
				$list[] = $temp;
				$result['cplist'][] = $temp;
			}
			
		}
		
	}
	echoJSON($result);